/*
@title: SprigClick
@description: SprigClick is a simple clicker game where the main objective is to achieve a higher score. Players can earn money by clicking, and use that money to purchase upgrades that increase their earnings per click and activate an autoclicker. The game focuses on progressing through these upgrades to maximize the score.
@author: CatR3kd
@tags: ['endless']
@addedOn: 2023-01-06
*/


// Sprites

setLegend(
  [",", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["1", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLL2222LLLLLLL
LLLLL2222LLLLLLL
LLL22LL22LLLLLLL
LLL22LL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLL2222222222LLL
LLL2222222222LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["2", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22222222LLLLL
LLL22222222LLLLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL2222222222LLL
LLL2222222222LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["3", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22222222LLLLL
LLL22222222LLLLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLL22222222LLLLL
LLL22222222LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["4", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL2222222222LLL
LLL2222222222LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["5", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL2222222222LLL
LLL2222222222LLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22222222LLLLL
LLL22222222LLLLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLL22222222LLLLL
LLL22222222LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["6", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLL22222222LLL
LLLLL22222222LLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22222222LLLLL
LLL22222222LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL2222222222LLL
LLL2222222222LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["7", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL2222222222LLL
LLL2222222222LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLL22LLLLL
LLLLLLLLL22LLLLL
LLLLLLLLL22LLLLL
LLLLLLLLL22LLLLL
LLLLLLLLL22LLLLL
LLLLLLLLL22LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["8", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["9", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLL22222222LLL
LLLLL22222222LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL2222222222LLL
LLL2222222222LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLL22222222LLLLL
LLL22222222LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["0", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["$", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLL22LLLLLLL
LLLLL2222222LLLL
LLLLL2222222LLLL
LLL22LL22LLLLLLL
LLL22LL22LLLLLLL
LLL22LL22LLLLLLL
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LLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLLLL22LLLLLLLLL
LLLLL22LLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  [")", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLL22LLLLL
LLLLLLLLL22LLLLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLL22LLLLL
LLLLLLLLL22LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["m", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LL22222LL22222LL
LL22222LL22222LL
LL22LLL22LLL22LL
LL22LLL22LLL22LL
LL22LLL22LLL22LL
LL22LLL22LLL22LL
LL22LLL22LLL22LL
LL22LLL22LLL22LL
LL22LLLLLLLL22LL
LL22LLLLLLLL22LL
LL22LLLLLLLL22LL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["p", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22222222LLLLL
LLL22222222LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22222222LLLLL
LLL22222222LLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["c", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLL22222222LLL
LLLLL22222222LLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLLLL22222222LLL
LLLLL22222222LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["w", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LL22LL22LLL
LLL22LL22LL22LLL
LLL22LL22LL22LLL
LLL22LL22LL22LLL
LLL22LL22LL22LLL
LLL22LL22LL22LLL
LLL22LL22LL22LLL
LLL22LL22LL22LLL
LLL2222LL2222LLL
LLL2222LL2222LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["a", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL2222222222LLL
LLL2222222222LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["x", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLL22LL22LLLLL
LLLLL22LL22LLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLL22LL22LLLLL
LLLLL22LL22LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["u", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["t", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL2222222222LLL
LLL2222222222LLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["o", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["l", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22222222222LL
LLL22222222222LL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["i", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL2222222222LLL
LLL2222222222LLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLL2222222222LLL
LLL2222222222LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["k", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLL22LLLLL
LLL22LLLL22LLLLL
LLL222222LLLLLLL
LLL222222LLLLLLL
LLL22LLLL22LLLLL
LLL22LLLL22LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["s", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLL22222222LLL
LLLLL22222222LLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLLLLLLLLLL22LLL
LLL22222222LLLLL
LLL22222222LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["r", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL222222222LLLL
LLL222222222LLLL
LLL22LLLLLLL22LL
LLL22LLLLLLL22LL
LLL22LLLLLLL22LL
LLL22LLLLLLL22LL
LLL222222222LLLL
LLL222222222LLLL
LLL22LLLL22LLLLL
LLL22LLLL22LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["g", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLLLL22222222LLL
LLLLL22222222LLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LL222222LLL
LLL22LL222222LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLL222222LLLLL
LLLLL222222LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["b", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22222222LLLLL
LLL22222222LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22222222LLLLL
LLL22222222LLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22222222LLLLL
LLL22222222LLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["y", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLL22LLLLLL22LLL
LLLLL22LL22LLLLL
LLLLL22LL22LLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLL22LLLLLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["d", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL222222222LLLL
LLL222222222LLLL
LLL22LLLLLLL22LL
LLL22LLLLLLL22LL
LLL22LLLLLLL22LL
LLL22LLLLLLL22LL
LLL22LLLLLLL22LL
LLL22LLLLLLL22LL
LLL22LLLLLLL22LL
LLL22LLLLLLL22LL
LLL222222222LLLL
LLL222222222LLLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`],
  ["e", bitmap`
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL
LLL2222222222LLL
LLL2222222222LLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22222222LLLLL
LLL22222222LLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL22LLLLLLLLLLL
LLL2222222222LLL
LLL2222222222LLL
LLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLL`]
);


// Game vars

let money = 0;
let mpc = 1;
let auto = 0;


// Screen

let screen = map`..............`;
setMap(screen);

function updateScreen(){
  const scoreLine = addWhitespace(`$${money.toString()}`);
  const mpcLine = addWhitespace((mpc < 999)? `mpc(${mpc})-$50-w` : "mpc-max(999)");
  const autoLine = addWhitespace((auto < 5)? `auto(${auto})-$100-a` : "auto-max(5)");
  
  const newMap = `,,sprigclick,,
  ,,,,,,,,,,,,,,
  ______________
  ${scoreLine}
  ==============
  ${mpcLine}
  ${autoLine}
  ,,,,,,,,,,,,,,
  (press,i),,,,,
  ,,,,,,,,,,,,,,
  by,catr3kd,,,,`;
  setMap(newMap);
}

function addWhitespace(str){
  while(str.length < 14){
    str += ',';
  }

  return str;
}

updateScreen();


// Auto interval

setInterval(function(){
  money += auto;
  updateScreen();
}, 100);



// Inputs

onInput("i", () => {
  money += mpc;
  updateScreen();
});

onInput("w", () => {
  if((money > 49) && (mpc < 999)){
    money -= 50;
    mpc++;
  }
  updateScreen();
});

onInput("a", () => {
  if((money > 99) && (auto < 9)){
    money -= 100;
    auto++;
  }
  updateScreen();
});
